package com.gp.billsrecord.util

import android.os.Build
import com.yisa.module_glass.ui.adapters.Formatter
import java.util.*

/**
 * 日期格式化
 */
object DateUtil {
    fun formatDateTime(timeMills: Long, pattern: String): String {
        return Formatter.formatDateTime(timeMills, pattern)
    }

    fun parseMothStart(date: String): Long {
        return System.currentTimeMillis()
    }

    fun parseTimeEnd(date: String): Long {
        return System.currentTimeMillis()
    }

    fun formatNow(): String {
        return formatDateTime(System.currentTimeMillis(), "YYYY/MM/dd hh:mm")
    }

    fun toLong(): Long {
        return System.currentTimeMillis()
    }

    /**
     * 解析月份的开始
     */
    fun parseMonthStart(dateMs: Long): Long {
        val calender = Calendar.getInstance()
        calender.timeInMillis = dateMs
        calender.set(Calendar.DAY_OF_MONTH, 1)
        calender.set(Calendar.HOUR_OF_DAY, 0)
        calender.set(Calendar.MINUTE, 0)
        calender.set(Calendar.SECOND, 0)
        calender.set(Calendar.MILLISECOND, 0)
        return calender.timeInMillis
    }

    /**
     * * 解析月份的结束
     */
    fun parseMonthEnd(dateMs: Long): Long {
        val calender = Calendar.getInstance()
        calender.timeInMillis = dateMs
        val maxDay = calender.getActualMaximum(Calendar.DAY_OF_MONTH)
        calender.set(Calendar.DAY_OF_MONTH, maxDay)
        calender.set(Calendar.HOUR_OF_DAY, 23)
        calender.set(Calendar.MINUTE, 59)
        calender.set(Calendar.SECOND, 59)
        calender.set(Calendar.MILLISECOND, 999)
        return calender.timeInMillis
    }
}
